package main

import (
	"encoding/json"
	"fmt"
)

func main() {
	type Stu struct {
		Name string `json:"name"`
		Age  int    `json:"age"`
		like string
	}

	var stu Stu
	stu = Stu{
		Name: "lijun",
		Age:  29,
		like: "写代码",
	}

	fmt.Println(stu)

	// 结构体转json
	v, err := json.Marshal(stu)
	if err != nil {
		fmt.Println("有错")
	} else {
		fmt.Println(string(v))
	}

	// 结构体继承

	type Dog struct {
		Color string `json:"color"`
		Stu
	}
	stu1 := Stu{
		Name: "小黑",
		Age:  3,
		like: "吃屎",
	}
	dog := Dog{
		Color: "黑色",
		Stu:   stu1,
	}

	fmt.Println(dog)
	fmt.Println(dog.Name)
	fmt.Println(dog.Stu.Name)

}
